﻿//----------------------------------------------------

#region 命名空间

//    版权：
//    作者：
//建立时间：2012-09-11 00:00:33
//    描述：
//----------------------------------------------------
using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using System.Web.UI;
using WinnerCMS.Data;
using WinnerCMS.Model;
using WinnerCMS.Common;

#endregion

namespace WinnerCMS.BLL
{
    /// <summary>
    /// 业务逻辑类 WinnerCMS_CounterDiary 的摘要说明。
    /// </summary>
    public class CounterDiaryManage
    {
        private static readonly CounterDiaryDal Dal = new CounterDiaryDal();

        #region 添加

        /// <summary>
        /// 添加
        /// </summary>
        public void Add(CounterDiary model)
        {
            Dal.Add(model);
        }

        #endregion

        /// <summary>
        /// 删除日志
        /// </summary>
        /// <param name="strDateTime"></param>
        public void Delete(string strDateTime, UpdatePanel UpdatePanel1)
        {
            Dal.Delete(DateTime.Parse(strDateTime));
            MsgBox.Message("删除成功！", UpdatePanel1);
        }

        /// <summary>
        /// 清空日志
        /// </summary>
        public void Delete()
        {
            Dal.Delete();
        }

        /// <summary>
        /// 绑定数据
        /// </summary>
        /// <param name="pp"></param>
        /// <returns></returns>
        public IList<CounterDiary> BindList(PagingParam pp)
        {
            return Dal.BindList(pp);
        }

        /// <summary>
        /// 按月统计访问量
        /// </summary>
        /// <returns></returns>
        public IList<CounterDiary> Month()
        {
            return Dal.Month();
        }

        /// <summary>
        /// 按日统计访问量
        /// </summary>
        /// <returns></returns>
        public IList<CounterDiary> Day()
        {
            return Dal.Day();
        }

        /// <summary>
        /// 按小时统计访问量
        /// </summary>
        /// <returns></returns>
        public IList<CounterDiary> Hour()
        {
            return Dal.Hour();
        }

        /// <summary>
        /// 按IP统计访问量
        /// </summary>
        /// <returns></returns>
        public IList<CounterDiary> Where()
        {
            return Dal.Where();
        }

        /// <summary>
        /// 统计在线人数
        /// </summary>
        /// <returns></returns>
        public int TotalOnline()
        {
            CMSConfig config = CMSConfig.Instance();
            return Dal.TotalOnline(config.Counter.OnlineActiveTime);
        }

        /// <summary>
        /// 被访问页面统计(前20位)
        /// </summary>
        /// <returns></returns>
        public void Page(BaseDataBoundControl GV_List)
        {
            GV_List.DataSource = Dal.Page();
            GV_List.DataBind();
        }

        /// <summary>
        /// 总访问量
        /// </summary>
        /// <returns></returns>
        public decimal AllCount()
        {
            object obj = Dal.AllCount();
            try
            {
                return Convert.ToDecimal(obj);
            }
            catch
            {
                return 0;
            }
        }

        /// <summary>
        /// 来路统计(前20位)
        /// </summary>
        /// <returns></returns>
        public void Come(BaseDataBoundControl gvList)
        {
            gvList.DataSource = Dal.Come();
            gvList.DataBind();
        }

        /// <summary>
        /// 今年访问量
        /// </summary>
        /// <returns></returns>
        public string ThisYear()
        {
            object obj = Dal.ThisYear();
            if (obj == null)
            {
                return "0";
            }
            return obj.ToString();
        }

        /// <summary>
        /// 本月访问量
        /// </summary>
        /// <returns></returns>
        public string ThisMonth()
        {
            object obj = Dal.ThisMonth();
            if (obj == null)
            {
                return "0";
            }
            return obj.ToString();
        }
    }
}